package org.example.coursemangementserver.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.coursemangementserver.pojo.entity.Student;
import org.example.coursemangementserver.pojo.vo.student.StudentAuditingInfoVO;
import org.example.coursemangementserver.pojo.vo.student.StudentVO;

import java.util.List;

/**
 * @author 12438
 */
public interface StudentMapper extends BaseMapper<Student> {

    /**
     * 通过学号查找对应的学生数据
     * @param studentNum 学号
     * @return
     */
    @Select("select * from students where student_num = #{studentNum}")
    Student selectByStudentNum(String studentNum);

    /**
     * 获取待审核的学生信息总数
     * @return
     */
    @Select("select count(*) from students where status = 0")
    Integer getStudentAuditingCount();

    /**
     * 获取待审核的学生信息
     * @param start 分页起始位置
     * @param pageSize 分页大小
     * @return 待审核学生信息列表
     */
    List<StudentAuditingInfoVO> getStudentAuditing(@Param("start") Integer start, @Param("pageSize") Integer pageSize);

    /**
     * 获取正常学生信息的总数
     * @param name
     * @return
     */
    Integer getStudentTotal(@Param("name") String name);

    /**
     * 获取所有正常学生信息
     * @param start
     * @param pageSize
     * @param name
     * @return
     */
    List<StudentVO> getStudentList(@Param("start") Integer start, @Param("pageSize") Integer pageSize, @Param("name") String name);

    @Select("select * from students where student_id = #{studentId}")
    Student getStudentById(long studentId);

    List<Long> findStudentIdsByGrade(Integer grade);

    /**
     * 通过学号和姓名查找学生
     * @param studentNum
     * @param studentName
     * @return
     */
    @Select("select * from students where student_num = #{studentNum} and name = #{studentName}")
    Student getStudentByNumAndName(@Param("studentNum") String studentNum, @Param("studentName") String studentName);
}

